exports.searchJoinMember = function (req, res) {

    //获取restful参数
    var restfulParams = req.routeInfo.restfulParams;

    //最终结果
    var resultData = {};

    var oa_type = restfulParams.oa_type;

    var url = 0;

    var uid = 0;

    var uidArr = 0;

    if (oa_type == 0) {

        url = CORE_APIConfig.coreAPI.searchBulkPurchaseActivityUser + "/bpau_oaid/" + restfulParams.oa_id;
        uid = "bpau_uid as uid"

    } else if (oa_type == 1) {

        url = CORE_APIConfig.coreAPI.searchVoteActivityUser + "/vau_oaid/" + restfulParams.oa_id;
        uid = "vau_uid as uid"

    } else if (oa_type == 2) {

        url = CORE_APIConfig.coreAPI.searchBargainJoin + "/bj_oaid/" + restfulParams.oa_id;
        uid = "bj_uid as uid"

    } else if (oa_type == 5) {

        url = CORE_APIConfig.coreAPI.searchDiscountsActivityUserSearch + "/dau_oaid/" + restfulParams.oa_id;
        uid = "dau_uid as uid"

    } else {
        return RES.response(res, false, "该活动无参加人员数据");
    }

    //任务流创建
    async.waterfall([

            function (cb) {
                R.SEND_HTTP(
                    req,
                    {
                        url: url,
                        method: 'POST',
                        data: {
                            fields: [uid].join(",")
                        }
                    },
                    function (err, data) {
                        //判断是否有错误信息
                        if (err) {
                            return cb(err, data);
                        }

                        uidArr = data.data;

                        resultData.joinUser = uidArr;

                        cb();
                    }
                );

            },
            function (cb) {

                //创建添加任务
                var tasks = [];

                //循环节点列表
                uidArr.forEach(function (item, i) {

                    //创建每一个插入任务
                    tasks.push(function (cb) {

                        R.SEND_HTTP(
                            req,
                            {
                                url: CORE_APIConfig.coreAPI.userSearch + "/u_id/"+item.uid,
                                method: 'POST',
                                data: {
                                    fields: ["u_header_url", "u_nickname"].join(",")
                                }
                            },
                            function (err, data) {

                                if(err){
                                    return RES.response(res, false, data);
                                }

                                item.u_header_url = data.data[0].u_header_url;
                                item.u_nickname = data.data[0].u_nickname;

                                cb();
                            }
                        );
                    });
                });

                async.waterfall(tasks, cb);

            },
        ], function (err, result) {

            //返回最终拼接结果
            RES.response(res, true, resultData);

        }
    );

}